; +
(function () {
    class ZUI {
        constructor() {
 
        }
        circuit(options) {
            new Circuit(options)
        }
    }
    self.ZUI = new ZUI()

    var cc, circuit_defult = '.z-input-beautiful'

    function Circuit() {
        cc = this
        cc.ipt_circuit = $(circuit_defult)
        $.each(cc.ipt_circuit, function (indexInArray, valueOfElement) {
            cc.createTemplate(valueOfElement)
        });
    }
    Circuit.prototype.createTemplate = function (value) {
        console.log('createTemplate', value);
        var ipt = $(value),
            z_text_arr = ipt.attr('present').split('|'),
            z_text = ipt.prop('checked') ? z_text_arr[1] : z_text_arr[0],
            z_check = ipt.prop('checked') ? '' : 'z-circuit-block-nosel',
            temp = `
                <div class="z-circuit-block ${z_check}">
                    <em>${z_text}</em>
                    <i></i>
                </div>
             `;
        console.log('checked', ipt.prop('checked'), 'attr', ipt.attr('checked'), 'z_check', z_check);
        ipt.hide();
        ipt.after(temp);
        cc.circuitClick()
    }, Circuit.prototype.circuitClick = function () {
        $('.z-circuit-block').unbind('click').click(function () {
            var ipts = $(this).prevAll(circuit_defult),
                txts = ipts.attr('present').split('|')
            var cir = $(this);
            console.log('circuitClick checked', cir.prop('checked'));
            if (cir.attr('class').indexOf('z-circuit-block-nosel') == -1) {
            // if (cir.prop('checked')) {
                cir.addClass('z-circuit-block-nosel')
                cir.find('em').text(txts[0])
                ipts.prop('checked', false);
                console.log(ipts.attr('checked'));
            } else {
                cir.removeClass('z-circuit-block-nosel')
                cir.find('em').text(txts[1])
                ipts.prop('checked', 'true')
                console.log(ipts.attr('checked'));
            }
        })
    }
})(window)